<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>new (MusicBank)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File music_bank.rb, line 49</span>
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">location</span>, <span class="ruby-identifier">files</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">safe</span>=<span class="ruby-keyword kw">false</span>)
    <span class="ruby-ivar">@location</span> = <span class="ruby-identifier">location</span>.<span class="ruby-identifier">sub</span>(<span class="ruby-regexp re">/\/$/</span>, <span class="ruby-value str">&quot;&quot;</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\\/</span>, <span class="ruby-value str">&quot;/&quot;</span>);
    <span class="ruby-keyword kw">begin</span>; <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-ivar">@location</span>); <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SystemCallError</span>; <span class="ruby-keyword kw">end</span>; <span class="ruby-comment cmt">#Create if doesnt exists</span>
    <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>(<span class="ruby-ivar">@location</span>);
    <span class="ruby-comment cmt">#/\.(mp3)$/</span>
    <span class="ruby-constant">EXTENSIONS</span>.<span class="ruby-identifier">map!</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">ext</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ext</span>.<span class="ruby-identifier">to_s</span>;}
    <span class="ruby-ivar">@exts</span> = <span class="ruby-value str">&quot;\.(&quot;</span><span class="ruby-operator">+</span><span class="ruby-constant">EXTENSIONS</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;|&quot;</span>)<span class="ruby-operator">+</span><span class="ruby-value str">&quot;)$&quot;</span>;
    <span class="ruby-ivar">@exts</span> = <span class="ruby-constant">Regexp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@exts</span>);
    <span class="ruby-ivar">@nosongs</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>;
    <span class="ruby-ivar">@songs</span> = <span class="ruby-identifier">files</span> <span class="ruby-operator">||</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">entries</span>(<span class="ruby-value str">&quot;.&quot;</span>);
    <span class="ruby-identifier">raise</span> <span class="ruby-constant">StandardError</span>, <span class="ruby-value str">&quot;Can't create a MusicBank object with no files&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@songs</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>;
    <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">safe</span>
      <span class="ruby-ivar">@songs</span> = <span class="ruby-ivar">@songs</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">song</span><span class="ruby-operator">|</span>
        <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">song</span> <span class="ruby-operator">=~</span> <span class="ruby-ivar">@exts</span>
          <span class="ruby-keyword kw">begin</span>; <span class="ruby-constant">Mp3Info</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">song</span>);
          <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">StandardError</span>; <span class="ruby-ivar">@nosongs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">song</span>; <span class="ruby-identifier">song</span> = <span class="ruby-keyword kw">nil</span>; <span class="ruby-keyword kw">end</span>;
        <span class="ruby-keyword kw">else</span>; <span class="ruby-identifier">song</span> = <span class="ruby-keyword kw">nil</span>; <span class="ruby-keyword kw">end</span>; 
        <span class="ruby-identifier">song</span>;
      <span class="ruby-keyword kw">end</span>
    <span class="ruby-keyword kw">end</span>
    <span class="ruby-ivar">@songs</span>.<span class="ruby-identifier">compact!</span>;
    <span class="ruby-ivar">@generator</span> = <span class="ruby-ivar">@@generator</span>;
    <span class="ruby-ivar">@rename_format</span> = <span class="ruby-ivar">@@rename_format</span>;
    <span class="ruby-ivar">@run_play</span> = <span class="ruby-ivar">@@run_play</span>;
    <span class="ruby-ivar">@finder_options</span> = <span class="ruby-ivar">@@finder_options</span>;
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>